<?php
/**
 * Created by JetBrains PhpStorm.
 * User: admin
 * Date: 18.10.12
 * Time: 20:16
 * To change this template use File | Settings | File Templates.
 */

class Mylab_Validators_PasswordConfirm extends Zend_Validate_Abstract{

    const NOT_MATCH = 'notMatch';

    protected $_messageTemplates = array(
        self::NOT_MATCH => 'Пароли не совпадают',
    );

    public function isValid($value, $context = null)
    {
        if (is_array($context))
        {
            if ((isset($context['password'])) &&
                ($value == $context['password']))
            {
                return true;
            }
        }
        elseif(is_string($context) &&
            ($value == $context))
        {
            return true;
        }
        $this->_error(self::NOT_MATCH);
        return false;
    }
}
